package array;

public class WhyUseArray {
	public static void main(String[] args) {
		// 需求保存咱们班所有的年纪, 24个人就要创建24个变量，起名。内存地址
		int zhangNaiShengAge = 23;
		int tianKeXinAge = 22;
		int kangQiRongAge = 22;
		int jiangHongAge = 22;
		
		// 创建一个数组，用来保存24个人的, 1.解决了变量名的问题 2.变量的位置连续的
		int[] ages = {23,22,22,22}; 
		System.out.println(ages[0]);  // 数组的下标整数，从0开始
		System.out.println(ages[1]);
		System.out.println(ages[2]);
		System.out.println(ages[3]);
		
		// 静态定义数组，声明的同时直接赋值, 一旦开辟了堆空间长度不能变
		String[] names = {"张乃升","田可馨","康淇溶","姜宏"};
		boolean[] graduated = {true,false,false,true};
		double[] heights = {1.9,1.69,1.55,1.62};
		char[] sex = {'男','女','女','女'};
		
		System.out.println(names[0]);
		System.out.println(names[1]);
		System.out.println(names[2]);
		System.out.println(names[3]);
 	}
}
